package array

import (
	"sort"
)

// 贪心算法
func findContentChildren(g []int, s []int) int {
	sort.Ints(g)
	sort.Ints(s)

	useMap := map[int]struct{}{}
	res := 0
	for _, v1 := range g {
		for i, v2 := range s {
			if v1 > v2 {
				continue
			} else {
				if _, ok := useMap[i]; !ok {
					res++
					useMap[i] = struct{}{}
					break
				}
			}
		}
	}
	return res
}
